/*
	File:		Game.h
	Course:		SGD 1303
	Author:		dmonroe
	Purpose:	CGame class controls the entire game
				& manages the SGD Wrappers
*/



#pragma once


#define WIN32_LEAN_AND_MEAN
#include <Windows.h>


//**************************************************
// Forward class declarations
//	- reduce header dependency
//	- reduce compile time
class CSGD_Direct3D;
class CSGD_DirectInput;
class CSGD_TextureManager;
class CSGD_XAudio2;
class CSGD_EventSystem;
class CSGD_MessageSystem;
class IMessage;

class CEntity;
class CEntityManager;


//**************************************************
// CGame class
//	- singleton (only ONE object can be created at any time)
//	- manages SGD Wrappers
//	- handles the gameplay
class CGame
{
public:
	//**********************************************
	// SINGLETON ACCESSORS
	static CGame*	GetInstance		( void );
	static void		DeleteInstance	( void );


	//**********************************************
	// Initialize the game
	void Initialize( HWND hWnd, HINSTANCE hInstance,
					 int nWindowWidth, int nWindowHeight,
					 bool bWindowed );

	// Run the game
	bool Main( void );

	// Terminate the game
	void Terminate( void );


	//**********************************************
	// Window Accessors:	
	int		GetWidth	( void ) const	{	return m_nWidth;	}
	int		GetHeight	( void ) const	{	return m_nHeight;	}
	bool	GetWindowed	( void ) const	{	return m_bWindowed;	}

	
	//**********************************************
	// Message Callback Procedure:
	static void MessageProc	( IMessage* pMsg );



private:
	//**********************************************
	// SINGLETON MEMBER (dynamically allocated)
	static CGame*	s_pInstance;

	// Prevent access to constructors & destructor
	CGame(void);
	~CGame(void);
	CGame( const CGame& );					// copy ctor
	CGame& operator= ( const CGame& );		// assignment op


	//**********************************************
	// Helper Functions
	bool	Input	( void );
	void	Update	( void );
	void	Render	( void );


	//**********************************************
	// Window Attributes
	HWND					m_hWnd;
	HINSTANCE				m_hInstance;
	int						m_nWidth;
	int						m_nHeight;
	bool					m_bWindowed;


	//**********************************************
	// SGD Wrappers
	CSGD_Direct3D*			m_pD3D;
	CSGD_DirectInput*		m_pDI;
	CSGD_TextureManager*	m_pTM;
	CSGD_XAudio2*			m_pXA;
	CSGD_MessageSystem*		m_pMS;
	CSGD_EventSystem*		m_pES;

	CEntityManager*			m_pEM;


	//**********************************************
	// Assets
	


	//**********************************************
	// Game Entities

	// Fire Timer
	float					m_fFireTimer;


	// Current Time (in milliseconds)
	DWORD					m_dwCurrTime;


	// Frame-rate
	unsigned int			m_unFPS;
	unsigned int			m_unFrames;
	float					m_fFPSTimer;
};

